/**
 * 
 */
package org.extdev.device.ltr;

import java.io.Serializable;
import java.util.LinkedList;

import org.extdev.libraries.ltr.LTRAPIFacadeFactory;
import org.extdev.libraries.ltr.LTRAPILibraryFacade;
import org.extdev.libraries.ltr.LTRException;


/**
 * @author LAP
 *
 */
public class LTRU1Crate implements LTRCrate, Serializable {
	private static final long serialVersionUID = 1L;
	
	private String serialNumberOfCrate;
	private LinkedList<Short> modules;
	private LTRAPILibraryFacade facade;
	
	public LTRU1Crate(String sn) throws LTRException {
		super();
		if (sn == null || sn.isEmpty()) throw new IllegalArgumentException("Serial number must be not null or empty");
		serialNumberOfCrate = sn;
		facade = LTRAPIFacadeFactory.getInstance().getLTRCrateFacade(sn);
		facade.openLTR();
		modules = facade.getModules();
		facade.closeLTR();
	}
	
	@Override
	public LinkedList<Short> getModules() {
		return modules;
	}
	
	@Override
	public String getSerialNumberOfCrate() {
		return serialNumberOfCrate;
	}
	
	@Override
	public String toString() {
		return serialNumberOfCrate;
	}
}
